package tablet.module_user.fragment;

import android.graphics.Bitmap;
import android.view.View;
import android.widget.Button;

import com.google.gson.Gson;
import com.lib.bean.ConfigBean;
import com.lib.fastkit.db.shared_prefrences.SharedPreferenceManager;
import com.lib.ui.fragment.BaseWebFragment;
import com.tencent.smtt.sdk.WebView;

import butterknife.BindView;
import butterknife.OnClick;
import tablet.module_user.R;
import tablet.module_user.R2;

public class StudentXieYiFragment extends BaseWebFragment {

    @BindView(R2.id.btn_xieyi_cancel)
    Button btnXieyiCancel;
    @BindView(R2.id.btn_xieyi_confirm)
    Button btnXieyiConfirm;

    ConfigBean configBean;

    @Override
    protected void myOnPageStarted(WebView webView, String s, Bitmap bitmap) {

    }

    @Override
    protected void myShouldOverrideUrlLoading(WebView webView, String url) {

    }

    @Override
    protected void myOnPageFinished(WebView webView, String s) {

    }

    @Override
    protected void onCreateView(WebView webView) {

        String json = SharedPreferenceManager.getInstance(getActivity()).getUserCache().getConfigJson();
        configBean = new Gson().fromJson(json, ConfigBean.class);

        String xieyiUrl = configBean.getObj().getService_protocol();
        webView.loadUrl(xieyiUrl);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_student_xieyi;
    }

    @OnClick({R2.id.btn_xieyi_cancel, R2.id.btn_xieyi_confirm})
    public void onViewClicked(View view) {
        int i = view.getId();
        if (i == R.id.btn_xieyi_cancel) {

            studentClickListener.clickCancel();

        } else if (i == R.id.btn_xieyi_confirm) {

            studentClickListener.clickConfirm();

        }
    }


    public interface StudentClickListener {
        void clickCancel();

        void clickConfirm();
    }

    public StudentClickListener studentClickListener;

    public void setStudentClickListener(StudentClickListener studentClickListener) {
        this.studentClickListener = studentClickListener;
    }

}
